package aidturith.ihm.action.key;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import aidturith.ihm.component.FilterTextField;
import aidturith.ihm.panel.proto.TablePanel;

public class EscapeAction extends AbstractAction {

	private static final long serialVersionUID = 1L;

	private TablePanel panel;
	private FilterTextField filter;

	public EscapeAction(TablePanel panel) {
		this.panel = panel;
	}

	public EscapeAction(FilterTextField filter) {
		this.filter = filter;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(panel != null) {
			panel.clearSelection();
			panel.getDelete_jb().setEnabled(false);
			if(panel.getTable().isEditing())
				panel.getTable().getCellEditor().stopCellEditing();
			panel.updateTableInfo();
		}
		else if(filter != null)
			filter.clearFilter();
	}

}
